﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>hinnn-hiprint</title>
    <!-- hiprint -->
    <link href="~/hiprint/css/hiprint.css" rel="stylesheet" />
    <link href="~/hiprint/css/print-lock.css" rel="stylesheet" />
    @* <link href="hiprint/css/print-lock.css" media="print" rel="stylesheet"> *@

    <!-- jQuery (hiprint 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <!-- polyfill.min.js解决浏览器兼容性问题v6.26.0-->
    <script src="~/hiprint/polyfill.min.js"></script>
    <!-- hiprint 核心js-->
    <script src="~/hiprint/hiprint.bundle.js"></script>
    <!-- 条形码生成组件-->
    <script src="~/hiprint/plugins/jsbarcode.all.min.js"></script>
    <!-- 二维码生成组件-->
    <script src="~/hiprint/plugins/qrcode.js"></script>
    <!-- 调用浏览器打印窗口helper类，可自行替换-->
    <script src="~/hiprint/plugins/jquery.hiwprint.js"></script>
</head>
<body>
    <div>
        <button class="layui-btn layui-btn-primary layui-border-blue" onclick="PrintThis()">打印</button>
    </div>

    <div id="templateDesignDiv" style="margin-left:auto;margin-right:auto;width:800px;margin-top:-40px">
    </div>

    <script>

        $(function () {
            print();
        })
        //?HiPrint初始化和使用代码
        hiprint.init();
        //创建打印模板对象
        var hiprintTemplate;
        // <!--文本 打印面板添加文本元素-- >
        var obj = {
            "panels": [{
                "index": 0, "paperType": "A4", "height": 297, "width": 210, "paperHeader": 43.5, "paperFooter": 801,
                "printElements": [{
                    "options": { "left": 7.5, "top": 55.5, "height": 9, "width": 562.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 7.5, "top": 129, "height": 9, "width": 562.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 85.5, "top": 55.5, "height": 399, "width": 9 },
                    "printElementType": { "type": "vline" }
                }, {
                    "options": { "left": 7.5, "top": 55.5, "height": 399, "width": 9 },
                    "printElementType": { "type": "vline" }
                }, {
                    "options": { "left": 85.5, "top": 96, "height": 9, "width": 484.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 288, "top": 108, "height": 9.75, "width": 120, "title": "生产工单", "fontFamily": "Microsoft YaHei", "fontSize": 15, "fontWeight": "bolder" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 7.5, "top": 160.5, "height": 9, "width": 390 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 7.5, "top": 192, "height": 9, "width": 390 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 7.5, "top": 223.5, "height": 9, "width": 390 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 15, "top": 141, "height": 9.75, "width": 120, "title": "生产工单号", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 22.5, "top": 172.5, "height": 9.75, "width": 120, "title": "订单编号", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 24, "top": 204, "height": 9.75, "width": 120, "title": "客户编号", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 7.5, "top": 253.5, "height": 9, "width": 390 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 24, "top": 235.5, "height": 9.75, "width": 120, "title": "产品编号", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 7.5, "top": 283.5, "height": 9, "width": 562.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 24, "top": 264, "height": 9.75, "width": 120, "title": "产品名称", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 24, "top": 291, "height": 9.75, "width": 120, "title": "规格型号", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 7.5, "top": 307.5, "height": 9, "width": 562.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 570, "top": 55.5, "height": 399, "width": 9 },
                    "printElementType": { "type": "vline" }
                }, {
                    "options": { "left": 397.5, "top": 130.5, "height": 153, "width": 9 },
                    "printElementType": { "type": "vline" }
                }, {
                    "options": { "left": 7.5, "top": 328.5, "height": 9, "width": 562.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 27, "top": 313.5, "height": 9.75, "width": 120, "title": "批次号", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 7.5, "top": 349.5, "height": 9, "width": 562.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 7.5, "top": 370.5, "height": 9, "width": 562.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 85.5, "top": 394.5, "height": 9, "width": 484.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 7.5, "top": 415.5, "height": 9, "width": 562.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 21, "top": 334.5, "height": 9.75, "width": 120, "title": "工单数量", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 291, "top": 328.5, "height": 21, "width": 9 },
                    "printElementType": { "type": "vline" }
                }, {
                    "options": { "left": 316.5, "top": 333, "height": 9.75, "width": 120, "title": "需求日期", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 397.5, "top": 328.5, "height": 21, "width": 9 },
                    "printElementType": { "type": "vline" }
                }, {
                    "options": { "left": 21, "top": 354, "height": 9.75, "width": 120, "title": "工艺流程", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 25.5, "top": 390, "height": 9.75, "width": 120, "title": "子工单", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 7.5, "top": 454.5, "height": 9, "width": 562.5 },
                    "printElementType": { "type": "hline" }
                }, {
                    "options": { "left": 30, "top": 432, "height": 9.75, "width": 120, "title": "备注", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 19.5, "top": 469.5, "height": 9.75, "width": 120, "title": "创建日期：", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 402, "top": 469.5, "height": 9.75, "width": 120, "title": "审核人", "field": "审核人", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 175.5, "top": 141, "height": 9.75, "width": 120, "field": "productionWorkOrdersName", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 175.5, "top": 172.5, "height": 9.75, "width": 120, "field": "orderNumber", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 175.5, "top": 204, "height": 9.75, "width": 120, "field": "clientNo", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 175.5, "top": 235.5, "height": 9.75, "width": 120, "field": "productManageNode", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 175.5, "top": 264, "height": 9.75, "width": 120, "field": "productManageName", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 175.5, "top": 291, "height": 9.75, "width": 120, "field": "productManageNumber", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 175.5, "top": 313.5, "height": 9.75, "width": 120, "field": "batchNo", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 154.5, "top": 334.5, "height": 9.75, "width": 76.5, "field": "ticketsNum", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 441, "top": 333, "height": 9.75, "width": 120, "field": "demandDate", "dataType": "datetime", "format": "yyyy/MM/dd", "fontSize": 12, "fontWeight": "bold" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 171, "top": 432, "height": 9.75, "width": 120, "field": "remark" },
                    "printElementType": { "type": "text" }
                }, {
                    "options": { "left": 465, "top": 469.5, "height": 9.75, "width": 120, "dataType": "datetime", "format": "yyyy/MM/dd HH:mm:ss" },
                    "printElementType": { "type": "text" }
                }], "paperNumberLeft": 565, "paperNumberTop": 819
            }]
        }
        console.log(obj)
        // <!--打印设计 -->
        hiprintTemplate = new hiprint.PrintTemplate({
            template: obj, // 模板json(object)
        });
        hiprintTemplate.design('#templateDesignDiv', { grid: true });
        function print() {
            var thisNo = location.href.split('=')[1];
            console.log(thisNo)
            $.ajax({
                url: '@ViewBag.FoundationRead' + "/api/WorkOrders/PageProductionBack",
                data: JSON.stringify({ ProNo: thisNo }),
                type: "post",
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    if (res.objects != null) {
                        let html = hiprintTemplate.getHtml(res.objects);
                        $("#templateDesignDiv").html(html);
                        //hiprintTemplate.print(res.objects);
                    }
                }
            })
            // <!-- 打印预览 -->

            // 打印完成清除面板
            $("#templateDesignDiv").empty()
        }
        function PrintThis() {
            var thisNo = location.href.split('=')[1];
            console.log(thisNo)
            $.ajax({
                url: '@ViewBag.FoundationRead' + "/api/WorkOrders/PageProductionBack",
                data: JSON.stringify({ ProNo: thisNo }),
                type: "post",
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    if (res.objects != null) {
                        hiprintTemplate.print(res.objects);
                    }
                }
            })
        }
    </script>

</body>
</html>
